package eu.irreality.dai.gameplay.controller.actions.direction;

import eu.irreality.dai.gameplay.controller.actions.ControllerAction;
import eu.irreality.dai.gameplay.entities.AliveEntity;
import eu.irreality.dai.gameplay.states.GameState;
import eu.irreality.dai.gameplay.states.MainState;
import eu.irreality.dai.gameplay.states.WhichDirectionState;
import eu.irreality.dai.gameplay.world.GameWorld;
import eu.irreality.dai.ui.keyboard.KeyProcessor;
import eu.irreality.dai.util.Direction;
import eu.irreality.dai.util.exceptions.GameException;
import eu.irreality.dai.util.exceptions.InternalErrorException;

public class ConfirmDirectionAction extends ControllerAction
{

    protected Direction dir;

    public ConfirmDirectionAction(KeyProcessor kp, GameWorld world,
	    AliveEntity entity)
    {
	super(kp, world, entity);
    }

    public void execute() throws GameException, InternalErrorException
    {
	GameState theState = kp.getCurrentState();
	assert theState instanceof WhichDirectionState : "ConfirmDirectionAction executed in state other than WhichDirectionState";
	WhichDirectionState myState = (WhichDirectionState) theState;
	myState.executeAction(dir);
	kp.setState(MainState.getInstance());
    }

}
